/**
 * <copyright>
 * </copyright>
 *

 */
package br.ufrn.dimap.MetricDslLanguage.metricDsl.impl;

import br.ufrn.dimap.MetricDslLanguage.metricDsl.*;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;

import org.eclipse.emf.ecore.impl.EFactoryImpl;

import org.eclipse.emf.ecore.plugin.EcorePlugin;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model <b>Factory</b>.
 * <!-- end-user-doc -->
 * @generated
 */
public class MetricDslFactoryImpl extends EFactoryImpl implements MetricDslFactory
{
  /**
   * Creates the default factory implementation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public static MetricDslFactory init()
  {
    try
    {
      MetricDslFactory theMetricDslFactory = (MetricDslFactory)EPackage.Registry.INSTANCE.getEFactory("http://www.ufrn.br/dimap/MetricDslLanguage/MetricDsl"); 
      if (theMetricDslFactory != null)
      {
        return theMetricDslFactory;
      }
    }
    catch (Exception exception)
    {
      EcorePlugin.INSTANCE.log(exception);
    }
    return new MetricDslFactoryImpl();
  }

  /**
   * Creates an instance of the factory.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public MetricDslFactoryImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public EObject create(EClass eClass)
  {
    switch (eClass.getClassifierID())
    {
      case MetricDslPackage.MODEL: return createModel();
      case MetricDslPackage.METRICS: return createMetrics();
      case MetricDslPackage.ACTIVITY_METRIC: return createActivityMetric();
      case MetricDslPackage.TASK_METRIC: return createTaskMetric();
      case MetricDslPackage.ARTEFACT_METRIC: return createArtefactMetric();
      default:
        throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
    }
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object createFromString(EDataType eDataType, String initialValue)
  {
    switch (eDataType.getClassifierID())
    {
      case MetricDslPackage.METRIC_TYPE:
        return createMetricTypeFromString(eDataType, initialValue);
      case MetricDslPackage.COLECT_TYPE:
        return createColectTypeFromString(eDataType, initialValue);
      case MetricDslPackage.METRIC_UNIT:
        return createMetricUnitFromString(eDataType, initialValue);
      default:
        throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
    }
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String convertToString(EDataType eDataType, Object instanceValue)
  {
    switch (eDataType.getClassifierID())
    {
      case MetricDslPackage.METRIC_TYPE:
        return convertMetricTypeToString(eDataType, instanceValue);
      case MetricDslPackage.COLECT_TYPE:
        return convertColectTypeToString(eDataType, instanceValue);
      case MetricDslPackage.METRIC_UNIT:
        return convertMetricUnitToString(eDataType, instanceValue);
      default:
        throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
    }
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Model createModel()
  {
    ModelImpl model = new ModelImpl();
    return model;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Metrics createMetrics()
  {
    MetricsImpl metrics = new MetricsImpl();
    return metrics;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ActivityMetric createActivityMetric()
  {
    ActivityMetricImpl activityMetric = new ActivityMetricImpl();
    return activityMetric;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public TaskMetric createTaskMetric()
  {
    TaskMetricImpl taskMetric = new TaskMetricImpl();
    return taskMetric;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ArtefactMetric createArtefactMetric()
  {
    ArtefactMetricImpl artefactMetric = new ArtefactMetricImpl();
    return artefactMetric;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public MetricType createMetricTypeFromString(EDataType eDataType, String initialValue)
  {
    MetricType result = MetricType.get(initialValue);
    if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
    return result;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String convertMetricTypeToString(EDataType eDataType, Object instanceValue)
  {
    return instanceValue == null ? null : instanceValue.toString();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ColectType createColectTypeFromString(EDataType eDataType, String initialValue)
  {
    ColectType result = ColectType.get(initialValue);
    if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
    return result;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String convertColectTypeToString(EDataType eDataType, Object instanceValue)
  {
    return instanceValue == null ? null : instanceValue.toString();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public MetricUnit createMetricUnitFromString(EDataType eDataType, String initialValue)
  {
    MetricUnit result = MetricUnit.get(initialValue);
    if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
    return result;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String convertMetricUnitToString(EDataType eDataType, Object instanceValue)
  {
    return instanceValue == null ? null : instanceValue.toString();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public MetricDslPackage getMetricDslPackage()
  {
    return (MetricDslPackage)getEPackage();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @deprecated
   * @generated
   */
  @Deprecated
  public static MetricDslPackage getPackage()
  {
    return MetricDslPackage.eINSTANCE;
  }

} //MetricDslFactoryImpl
